import request from "@/utils/request";
import {AxiosPromise} from "axios";

/**
 * 京东账单数据
 *
 * @param queryParams
 */
export function getJdBillPage(queryParams): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/jdBill/page',
		method: 'get',
		params: queryParams
	});
}


/**
 * 获取京东账单表单数据
 *
 * @param queryParams
 */
export function getJdBillForm(id: number) {
	return request({
		url: '/api/v1/jdBill/' + id + '/form',
		method: 'get'
	});
}

/**
 * 保存京东账单
 *
 * @param data
 */
export function saveJdBill(data) {
	return request({
		url: "/api/v1/jdBill",
		method: "post",
		data: data,
	});
}

/**
 * 删除京东账单
 *
 * @param ids
 */
export function deleteJdBill(ids: string) {
	return request({
		url: '/api/v1/jdBill/' + ids,
		method: 'delete'
	});
}

/**
 * 导入京东账单
 *
 * @param file
 */
export function importJdBill(file: any, storeCode: any) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/jdBill/jdBillImport/'+storeCode,
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}

/**
 * 导出京东账单
 *
 * @param ids
 * @returns
 */
export function exportJdBill(ids: any) {
	return request({
		url: '/api/v1/jdBill/_export?ids=' + ids,
		method: 'get',
		responseType: 'arraybuffer'
	});
}
